package _101SymmetricTree;

public class CSolution {

    public static void main(String[] args) {
        System.out.println("aa");
    }

    public boolean isSymmetric(TreeNode root) {
        if(root == null) {
            return true;
        }
        return process(root.left,root.right);
    }

    private boolean process(TreeNode n1,TreeNode n2) {
        if(n1==null && n2 == null) {
            return true;
        }
        if((n1==null && n2!=null) || (n1!=null&&n2==null) || n1.val != n2.val) {
            return false;
        }
        return process(n1.left,n2.right) && process(n1.right,n2.left);
    }
}
